<%--
  Created by IntelliJ IDEA.
  User: ZhuChunXiao
  Date: 2017/5/23
  Time: 18:07
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@ page isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
  String path = request.getContextPath();
  String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>

<div id="page-content">
  <div class="row">

    <div class="col-lg-12">
      <div class="panel">
        <%--<div class="panel-heading">--%>
          <%--<h3 class="panel-title">员工异动总汇</h3>--%>
        <%--</div>--%>
        <div class="panel-body">
          <input type="hidden" id="parentId1" value="${parentId}">

          <div class="table-jqgrid">
            <table id="allchange_in_table"></table>
            <div id="allchange_in_page"></div>
          </div>
        </div>

        <div class="panel-footer">
          <a class="btn btn-default" id="apply-re-common4" href="javascript:void(0)">
            <i class="fa fa-lg fa-mail-reply"></i> 返回视图
          </a>
        </div>
      </div>
    </div>

  </div>
</div>

<script>

  $(function(){

    init_grid_allchange();
    jQuery("#allchange_in_table").jqGrid('setGridWidth',  $('div').data("table_global_width")-66);

  });

  function init_grid_allchange() {

    __init_jqgrid('allchange_in_table', 'allchange_in_page',
            '<%=path%>/com/allChange/list?parentId='+$("#parentId1").val(),
            ["异动类型","异动时间","操作","id"],
            [
              {name:'type',index:'type',sortable:true,search:true,width:100,searchoptions:{sopt:['cn']}},
              {name:'createdate',index:'createdate',sortable:true,search:true,width:100,searchoptions:{sopt:['cn']}},
              {name:'act',index:'act', width:210,sortable:false,search:false,fixed:true,formatter: actFormat},
              {name:'id',index:'id',search:false,hidden:true}
            ],
            true,true
    );

  }

  function typeFormat(cellvalue, options, rowObject){
    if(rowObject.type == "1"){
      cellvalue = "转正申请";
    }else if(rowObject.type == "2"){
      cellvalue = "续约申请";
    }else if(rowObject.type == "3"){
      cellvalue = "离职申请";
    }else if(rowObject.type == "4"){
      cellvalue = "调动申请";
    }else{
      cellvalue = "暂无";
    }
    return cellvalue;
  }

  function actFormat(cellvalue, options, rowObject){
    var id = rowObject.id;
    var toWhere=rowObject.type;
    if(toWhere=="转正申请"){
      cellvalue = '<button class="btn btn-white btn-sm" data-original-title="查看" onclick="fn_formal_read(\'' + id + '\');"><i class="fa fa-eye"> </i> 查看</button> ';
    }else if(toWhere=="续约申请"){
      cellvalue = '<button class="btn btn-white btn-sm" data-original-title="查看" onclick="fn_renewal_read(\'' + id + '\');"><i class="fa fa-eye"> </i> 查看</button> ';
    }else if(toWhere=="离职申请"){
      cellvalue = '<button class="btn btn-white btn-sm" data-original-title="查看" onclick="fn_quit_read(\'' + id + '\');"><i class="fa fa-eye"> </i> 查看</button> ';
    }else if(toWhere=="调动申请"){
      cellvalue = '<button class="btn btn-white btn-sm" data-original-title="查看" onclick="fn_transfer_read(\'' + id + '\');"><i class="fa fa-eye"> </i> 查看</button> ';
    }
    return cellvalue;
  }

  //转正read
  function fn_formal_read(id) {
    loadURL('<%=path%>/com/formal/toRead?allChangeId='+id, $('#s4'));
  }

  //续约read
  function fn_renewal_read(id) {
    loadURL('<%=path%>/com/renewal/toRead?allChangeId='+id, $('#s4'));
  }

  //离职read
  function fn_quit_read(id) {
    loadURL('<%=path%>/com/quit/toRead?allChangeId='+id, $('#s4'));
  }

  //调动read
  function fn_transfer_read(id) {
    loadURL('<%=path%>/com/transfer/toRead?allChangeId='+id, $('#s4'));
  }

  //返回视图
  $("#apply-re-common4").click(returnToHashUrl);

</script>